<div>
    <table style="width: 99%;">
        <tbody>
            <tr>
                <td width="80px" valign="top">Published</td>
                <td align="left"><input class="text" id="published" name="published"  style="width:200px" type="text" value="<?php if ($this->has_data('published')) echo date("Y-m-d H:i:s", $this->data['published']);?>" /></td>
                <td width="80px" valign="top"> Expired</td>
                <td align="left"><input class="text" id="expired" name="expired" type="text" style="width:200px" value="<?php $this->write_date('expired');?>" /></td>
            </tr>
        </tbody>
    </table>
</div>
<div>Content</div>
<div><textarea id="content" name="content"><?php $this->write('content');?></textarea></div>
<script type="text/javascript" src="<?php echo tos_cdn_url('tinymce', 'sys');?>/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="<?php echo tos_cdn_url('js', 'sys');?>/calendar.js"></script>
<script type="text/javascript">

tinyMCE.init({
    mode : "exact",
    elements : "content",
    theme : "advanced",
    skin : "o2k7",
    skin_variant : "silver",
    //plugins : "emotions,spellchecker,advhr,insertdatetime,preview", 
    plugins : "insertdatetime",
    // Theme options - button# indicated the row# only
    theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,|,outdent,indent,|,link,unlink,anchor,image,|,forecolor,backcolor,|,insertdate,inserttime",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",      
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true

});


var content = z.s('content');
var description = z.s('description');
var calendar = new z.Calendar();
var published = z.s('published');
var expired = z.s('expired');
published.onkeydown = function () {
    return false;
};
expired.onkeydown = function () {
    return false;
};
published.onclick = function (e) {
    set_datetime(this);
};
published.onmouseout = function (e) {
    calendar.autoHide(e);
};
expired.onclick = function (e) {
    set_datetime(this);
};
expired.onmouseout = function (e) {
    hide_datetime(e);
};

content.onchange = function () {
    description.value = this.innerHTML;
};
if ( ! published.value)
    published.value = z.parseTime(calendar.selectedDay);
//if ( ! expired.value)
//    expired.value = z.parseTime(calendar.selectedDay);

function set_datetime(target) {
    var offset = z.getAbsOffset(target);
    calendar.setPos(offset.left + 5, offset.top + 20);
    calendar.show(target.value);
    calendar.submit = function () {
    	target.value = z.parseTime(this.selectedDay);
    	this.hide();
    }
    
}

function hide_datetime(e) {
    calendar.autoHide(e);
}

/*
var zt = document.getElementById('zt');
zt.onclick = function () {
    calendar.setPos(68, 30);
    calendar.show(this.innerHTML);
    calendar.submit = change_sys_time;
};*/
</script>